#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+10;
int n,t,x,y,head[N],a[N],in[N],sum[N],sum1[N],mx[N],cnt,o,L;
struct w
{
	int to,nxt;
}b[N*2];
inline void add(int x,int y)
{
	b[++cnt].nxt = head[x];
	b[cnt].to = y;
	head[x] = cnt;
}
void dfs(int x,int y)
{
	if(in[x] == 1) {sum[x] = a[x],sum1[x] = 1; return;}
	for(int i = head[x];i;i = b[i].nxt)
		if(b[i].to != y)  
			dfs(b[i].to,x),sum[x] += sum[b[i].to],sum1[x] += sum1[b[i].to],mx[x] = max(mx[x],sum[b[i].to]);
	if(sum1[x] == 1)
	{
		if(a[x] != sum[x]) L = 1;
	}
	else
	{
		if(mx[x]>=sum[x]-mx[x])
		{
			if(a[x] < mx[x] || a[x] > sum[x]) L = 1;
			else sum[x] = (a[x]-mx[x])*2+(mx[x]*2-sum[x]);
		}
		else
		{
			if(a[x] < sum[x]/2+sum[x]%2 || a[x] > sum[x]) L = 1;
			else sum[x] = (a[x]-sum[x]/2-sum[x]%2)*2+sum[x]%2; 
		}
	}
}
signed main()
{
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&n); cnt = L = o = 0;
		for(int i = 1;i <= n;i++) scanf("%lld",&a[i]),head[i] = in[i] = sum[i] = sum1[i] = mx[i] = 0;
		for(int i = 1;i < n;i++) scanf("%lld%lld",&x,&y),add(x,y),add(y,x),in[x]++,in[y]++;
		if(n == 2)
		{
			if(a[1] == a[2]) printf("YES\n");
			else printf("NO\n");
			continue;
		}
		for(int i = 1;i <= n;i++) 
			if(in[i] > 1)
			{
				dfs(i,0),o = i;
				break;
			}
		if(L||sum[o]) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

